package org.mnj07.struts.hello;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;

public class HelloWorld {
  private String message;

  private String userName;

  private String detail;

  private String city;
  
  public HelloWorld() {
  }

  public String execute() {
    String text = "Hello " + getUserName();
    String c = getCity();
    if(c != null && !"".equals(c)){
      text += (" from " + c);
    }
    text += " !";
    setMessage(text);
    Calendar now = Calendar.getInstance();
    DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd KK:mm a");
    String formattedDate = dateFormat.format(now.getTime());
    setDetail(formattedDate);
    return "SUCCESS";
    // return "DETAILED-SUCCESS";
  }

  /**
   * @return the message
   */
  public String getMessage() {
    return message;
  }

  /**
   * @param message
   *          the message to set
   */
  public void setMessage(String message) {
    this.message = message;
  }

  /**
   * @return the userName
   */
  public String getUserName() {
    return userName;
  }

  /**
   * @param userName
   *          the userName to set
   */
  public void setUserName(String userName) {
    this.userName = userName;
  }

  /**
   * @param detail
   *          string
   */
  public String getDetail() {
    return detail;
  }

  /**
   * @return the detail
   */
  public void setDetail(String detail) {
    this.detail = detail;
  }
  
  public String getCity() {
    return city;
  }

  public void setCity(String city) {
    this.city = city;
  }
}
